package RatioGPUDMM;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Document {

    public String[] words;
    public int id;
    //public String category;


    public Document(int docid, String[] words) {
        this.id = docid;
        //this.category = category;
        this.words = words;
    }

    public static ArrayList<Document> LoadCorpus(String filename) {
        try {
            FileInputStream fis = new FileInputStream(filename);
            InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
            BufferedReader reader = new BufferedReader(isr);
            String line;
            ArrayList<Document> doc_list = new ArrayList();
            int docid = 0;
            while ((line = reader.readLine()) != null) {
                Document doc = new Document(docid++, line.trim().split("\\s+"));
                doc_list.add(doc);
            }
            return doc_list;
        } catch (Exception e) {
            System.out.println("Error while reading other file:" + e.getMessage());
            e.printStackTrace();
//	      return false;
        }
        return null;

    }
}
